$OpenBSD: patch-Modules_FindJava_cmake,v 1.16 2015/06/24 06:39:03 dcoppa Exp $
--- Modules/FindJava.cmake.orig	Mon Jun  1 17:56:08 2015
+++ Modules/FindJava.cmake	Wed Jun 24 07:52:35 2015
@@ -71,6 +71,8 @@
 
 include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindJavaCommon.cmake)
 
+set(MODJAVA_VER $ENV{MODJAVA_VER})
+
 # The HINTS option should only be used for values computed from the system.
 set(_JAVA_HINTS)
 if(_JAVA_HOME)
@@ -88,19 +90,27 @@ list(APPEND _JAVA_HINTS
   )
 # Hard-coded guesses should still go in PATHS. This ensures that the user
 # environment can always override hard guesses.
-set(_JAVA_PATHS
-  /usr/lib/java/bin
-  /usr/share/java/bin
-  /usr/local/java/bin
-  /usr/local/java/share/bin
-  /usr/java/j2sdk1.4.2_04
-  /usr/lib/j2sdk1.4-sun/bin
-  /usr/java/j2sdk1.4.2_09/bin
-  /usr/lib/j2sdk1.5-sun/bin
-  /opt/sun-jdk-1.5.0.04/bin
-  /usr/local/jdk-1.7.0/bin
-  /usr/local/jdk-1.6.0/bin
-  )
+if(MODJAVA_VER)
+  if(MODJAVA_VER MATCHES "^1\\.8\\+?$")
+    set(_JAVA_PATHS ${LOCALBASE}/jdk-1.8.0/bin)
+  else()
+    set(_JAVA_PATHS ${LOCALBASE}/jdk-1.7.0/bin)
+  endif()
+else(MODJAVA_VER)
+  set(_JAVA_PATHS
+    /usr/lib/java/bin
+    /usr/share/java/bin
+    /usr/local/java/bin
+    /usr/local/java/share/bin
+    /usr/java/j2sdk1.4.2_04
+    /usr/lib/j2sdk1.4-sun/bin
+    /usr/java/j2sdk1.4.2_09/bin
+    /usr/lib/j2sdk1.5-sun/bin
+    /opt/sun-jdk-1.5.0.04/bin
+    ${LOCALBASE}/jdk-1.7.0/bin
+    ${LOCALBASE}/jdk-1.8.0/bin
+    )
+endif(MODJAVA_VER)
 find_program(Java_JAVA_EXECUTABLE
   NAMES java
   HINTS ${_JAVA_HINTS}
@@ -137,7 +147,7 @@ if(Java_JAVA_EXECUTABLE)
       elseif(var MATCHES "java full version \"kaffe-([0-9]+\\.[0-9]+\\.[0-9_]+)\"")
         # Kaffe style
         set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
-      elseif(var MATCHES "openjdk version \"([0-9]+\\.[0-9]+\\.[0-9_]+)\"")
+      elseif(var MATCHES "openjdk version \"([0-9]+\\.[0-9]+\\.[0-9_]+.*)\"")
         # OpenJDK ver 1.7.x on OpenBSD
         set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
       else()
